//
//  MapDetailTableViewCell.m
//  markmap
//
//  Created by 甘世清 on 2024/3/29.
//

#import "MapDetailTableViewCell.h"

@implementation MapDetailTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)SQ_Style:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self.contentView.backgroundColor = UIColor.clearColor;
    [self.contentView addSubview:self.headerLabel];
    [self.headerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(50);
            make.left.equalTo(self.contentView).offset(12);
        make.centerY.equalTo(self.contentView);
    }];
    [self.contentView addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headerLabel.mas_right).offset(8);
        make.centerY.equalTo(self.headerLabel).offset(-8);
    }];
    
    [self.contentView addSubview:self.timeLabel];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headerLabel.mas_right).offset(8);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(4);
    }];
}
- (void)setModel:(PointModel *)model{
    _model = model;
    [self.headerLabel sd_setImageWithURL:SQURLImage(model.portrait)];
    self.nameLabel.text = model.name;
    self.timeLabel.text = model.createTime;
}

- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = FONT_MEDIUM(16);
        _nameLabel.textColor = UIColor.whiteColor;
        _nameLabel.backgroundColor = UIColor.clearColor;
        _nameLabel.numberOfLines = 0;
    }
    return _nameLabel;
}

- (UIImageView *)headerLabel{
    if (!_headerLabel) {
        _headerLabel = [[UIImageView alloc]init];
        _headerLabel.contentMode = UIViewContentModeScaleAspectFill;
        _headerLabel.clipsToBounds = YES;
        _headerLabel.layer.cornerRadius = 25;
        _headerLabel.layer.masksToBounds = YES;
    }
    return _headerLabel;
}

- (UILabel *)timeLabel{
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc]init];
        _timeLabel.font = FONT_REGULAR(12);
        _timeLabel.textColor = SQColor999999;
        _timeLabel.backgroundColor = UIColor.clearColor;
    }
    return _timeLabel;
}
@end
